﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UITesting.WinControls;
using Microsoft.VisualStudio.TestTools.UITesting;

namespace MSN
{
    public class StatusMenu : WinMenu
    {
        private WinMenuItem online;
        private WinMenuItem offline;
        private WinMenuItem away;
        private WinMenuItem busy;
        private WinMenuItem statusMenuItem;
                
        public StatusMenu(UITestControl container) : base(container)
        {
            // this.SearchProperties[WinMenu.PropertyNames.Name] = "Context";
        }
       
        public WinMenuItem Online
        {
            get
            {
                if (this.online == null)
                {
                    this.online = new WinMenuItem(this);
                    this.online.SearchProperties[WinMenuItem.PropertyNames.Name] = ConstVariable.ONLINE;
                    this.online.WindowTitles.Add(ConstVariable.MSN);
                }

                return this.online;
            }
        }
        
        public WinMenuItem Away
        {
            get
            {
                if (this.away == null)
                {
                    this.away = new WinMenuItem(this);
                    this.away.SearchProperties[WinMenuItem.PropertyNames.Name] = ConstVariable.AWAY;
                    this.away.WindowTitles.Add(ConstVariable.MSN);
                }

                return this.away;
            }
        }

        public WinMenuItem Busy
        {
            get
            {
                if (this.busy == null)
                {
                    this.busy = new WinMenuItem(this);
                    this.busy.SearchProperties[WinMenuItem.PropertyNames.Name] = ConstVariable.BUSY;
                    this.busy.WindowTitles.Add(ConstVariable.MSN);
                }

                return this.busy;
            }
        }

        public WinMenuItem Offline
        {
            get
            {
                if (this.offline == null)
                {
                    this.offline = new WinMenuItem(this);
                    this.offline.SearchProperties[WinMenuItem.PropertyNames.Name] = ConstVariable.OFFLINE;
                    this.offline.WindowTitles.Add(ConstVariable.MSN);
                }

                return this.offline;
            }
        }

        
        public WinMenuItem this[StatusEnum status]
        {
            get { 
                if(this.statusMenuItem == null)
                {
                    this.statusMenuItem = new WinMenuItem(this);
                }

                switch(status)
                {                   
                    case StatusEnum.Away:
                        // this.statusMenuItem.SearchProperties[WinMenuItem.PropertyNames.Name] = ConstVariable.AWAY;
                        this.statusMenuItem = this.Away;
                        break;
                    case StatusEnum.Busy:
                        this.statusMenuItem.SearchProperties[WinMenuItem.PropertyNames.Name] = ConstVariable.BUSY;
                        break;
                    case StatusEnum.Offline:
                        this.statusMenuItem.SearchProperties[WinMenuItem.PropertyNames.Name] = ConstVariable.OFFLINE;
                        break;
                    case StatusEnum.Online:
                    default:
                        this.statusMenuItem.SearchProperties[WinMenuItem.PropertyNames.Name] = ConstVariable.ONLINE;
                        break;
                        
                }
                this.statusMenuItem.WindowTitles.Add(ConstVariable.MSN);
                return this.statusMenuItem;
            }
        }
    }   
}
